import * as echarts from "echarts";
import chinaMapDat from "../data/china.json";
echarts.registerMap("china", chinaMapDat);

export default function userEcharts(el) {
  const echartInstance = echarts.init(el);

  const setOptions = (options) => {
    echartInstance.setOption(options);
  };
  const setResize = () => {
    echartInstance.resize();
  };
  window.addEventListener("resize", () => {
    echartInstance.resize();
  });
  return {
    echartInstance,
    setOptions,
    setResize,
  };
}
